import React from 'react';
import { connect } from 'dva';
import { Layout } from 'antd';
import { getMenuData, getPageTitle } from '@ant-design/pro-layout';
import { Helmet } from 'react-helmet';
import { formatMessage } from 'umi-plugin-react/locale';
import styles from './UserLayout.less';

const { Content } = Layout;

const UserLayout = props => {
  const { route = { routes: [] } } = props;
  const { children, location = { pathname: '' } } = props;

  const { routes = [] } = route;
  const { breadcrumb } = getMenuData(routes);
  const title = getPageTitle({
    pathname: location.pathname,
    breadcrumb,
    formatMessage,
    title: '长宁区城市运行值守保障管理系统',
    menu: {},
    ...props,
  });

  return (
    <>
      <Helmet>
        <title>{title}</title>
        <meta name="description" content={title} />
      </Helmet>
      <Layout className={styles.user_layout_wrap}>
        <Content>{children}</Content>
      </Layout>
    </>
  );
};

export default connect(({}) => ({}))(UserLayout);
